package org.chinarjy.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.chinarjy.api.PersonApi;
import org.chinarjy.api.PersonSkillApi;
import org.chinarjy.api.SkillApi;
import org.chinarjy.dto.PersonInfo;
import org.chinarjy.dto.PersonSkillDto;
import org.chinarjy.dto.ResultApi;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/personskill")
public class PersonSkillController {
    @DubboReference(version = "${dubbo.provider.version}",check = false,application = "${dubbo.application.id}")
    SkillApi skillService;
    @DubboReference(version = "${dubbo.provider.version}",check = false,application = "${dubbo.application.id")
    PersonApi personService;
    @DubboReference(version = "${dubbo.provider.version}",check = false,application = "${dubbo.application.id")
    PersonSkillApi personSkillService;

    @RequestMapping("/add")
    ResultApi addAllPersonsToSkills(){
        log.info("PersonSkillController -->> addAllPersonsToSkills");
        ResultApi<List<PersonInfo>> allPersons = personService.getAllPersons();
        return skillService.addAllPersonToSkill(allPersons.getData());
    }

    @RequestMapping("/list")
    List<PersonSkillDto> getAllPersonSkillDto(){
        log.info("PersonSkillController -->> getAllPersonSkillDto" );
        return personSkillService.getAllPersonSkillDto().getData();
    }
}
